﻿using System.Collections.Generic;
using System.Drawing;
using System.Windows.Forms;
using CloudShot.Core.Types;

namespace CloudShot
{
	public partial class RecentShotsConteinerControl : UserControl
	{
		private IList<ShotInfo> _recentShots;
		//TODO use RecentShotsQueue and add events to RecentsShotQueue
		public IList<ShotInfo> RecentShots
		{
			get { return _recentShots; }
			set
			{
				_recentShots = value;

				if (value != null)
					FillRecentShots(value);
			}
		}

		public RecentShotsConteinerControl()
		{
			InitializeComponent();
		}

		private void FillRecentShots(IEnumerable<ShotInfo> shots)
		{
			foreach (ShotInfo recentShot in shots)
			{
				var recentShotControl = new RecentShotControl(recentShot);
				pnlMain.Controls.Add(recentShotControl);
			}
		}

		private void OnMainPanelPaint(object sender, PaintEventArgs e)
		{
			foreach (Control control in pnlMain.Controls)
			{
				e.Graphics.DrawLine(Pens.LightGray, 0, control.Top, pnlMain.Width, control.Top);
			}
		}
	}
}